<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title> - 注册</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">
    <script>if(window.top !== window.self){ window.top.location = window.location;}</script>
	<script src="js/jquery.min.js?v=2.1.4"></script>
	<script>
		 function test(){
//			var form = new FormData();
//  				form.append("username",$("#username").val());
//  				form.append("password",$("#password").val());
//				form.append("filed1",$("#filed1").val());
			 if($("#username").val().replace(/(^\s*)|(\s*$)/g, '')===''){
					alert("用户名不能为空");
				 	return false;
				}
			 if($("#pwd").val().replace(/(^\s*)|(\s*$)/g, '')===''){
					alert("密码不能为空");
				 	return false;
				}
			 if($("#filed1").val().replace(/(^\s*)|(\s*$)/g, '')===''){
					alert("确认密码不能为空");
				 	return false;
				}
			 if($("input[type='checkbox']").is(':checked')===false){
					alert("请勾选同意");
				 	return false;
				}
			var form=
				{
				username:$("#username").val(),
				password:$("#pwd").val(),
				filed1:$("#filed1").val()
				};
			 console.log(form);
　			$.ajax({
                url:"http://localhost:8081/lecture/register",
                type:"post",
				contentType: "application/json;charset=UTF-8",
                data:JSON.stringify(form),
				dataType: "json",
                success:function(data){
					//alert(data);
                  if(data===0){
					 window.location.href="login.html"; 
					}else{
						alert("注册失败，请重新注册"); 
					 }
                }
			});
		};
	</script>

</head>

<body class="gray-bg">

    <div class="middle-box text-center loginscreen   animated fadeInDown">
        <div>
            <div>

                <h1 class="logo-name">潮</h1>

            </div>
            <h3>欢迎注册</h3>
            <p>创建一个新账户</p>
            <form class="m-t" role="form" method="POST">
                <div class="form-group">
                    <input id="username" type="text" class="form-control" placeholder="请输入用户名" required="">
                </div>
                <div class="form-group">
                    <input id="pwd" type="password" class="form-control" placeholder="请输入密码" required="">
                </div>
                <div class="form-group">
                    <input id="filed1" type="password" class="form-control" placeholder="请再次输入密码" required="">
                </div>
                <div class="form-group text-left">
                    <div class="checkbox i-checks">
                        <label class="no-padding">
                            <input id="check" type="checkbox"><i></i> 我同意注册协议</label>
                    </div>
                </div>
                <button type="button" class="btn btn-primary block full-width m-b" onclick="test()">注 册</button>

                <p class="text-muted text-center"><small>已经有账户了？</small><a href="login.html">点此登录</a>
                </p>

            </form>
        </div>
    </div>

    <!-- 全局js -->
    <script src="js/jquery.min.js?v=2.1.4"></script>
    <script src="js/bootstrap.min.js?v=3.3.6"></script>
    <!-- iCheck -->
    <script src="js/plugins/iCheck/icheck.min.js"></script>
    <script>
        $(document).ready(function () {
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });
        });
		
    </script>

    
    

</body>

</html>
